<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Dari) AS no, *, CONVERT(CHAR(12), Dari, 103) tgl_dari, CONVERT(CHAR(12), Sampai, 103) tgl_sampai, CONVERT(CHAR(12), Tgl_Ijasah, 103) tglijasah FROM Pendidikan WHERE NIK='$nik' ) SELECT * FROM limit WHERE no='$no'",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Simpan";
}

include("../header.php");
?>
<script type="text/javascript">
	function LoadFocus(){
		document.forms[0].elements[0].focus();
	}
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){
		if(document.FEmployee.nik.value == "")
		{
			alert("Field : NIK tidak boleh kosong ...");
			document.FEmployee.nik.focus();
			return false;
		}

		if(document.FEmployee.jenjang.value == "")
		{
			alert("Field : Jenjang Pendidikan tidak boleh kosong ...");
			document.FEmployee.jenjang.focus();
			return false;
		}

		if(document.FEmployee.nama_kampus.value == "")
		{
			alert("Field : Nama Kampus tidak boleh kosong ...");
			document.FEmployee.nama_kampus.focus();
			return false;
		}
		
		if(document.FEmployee.tempat.value == "")
		{
			alert("Field : Tempat tidak boleh kosong ...");
			document.FEmployee.tempat.focus();
			return false;
		}
/*
		if(document.FEmployee.sampai_kelas.value == "")
		{
			alert("Field : Sampai Kelas tidak boleh kosong ...");
			document.FEmployee.sampai_kelas.focus();
			return false;
		}
		if(document.FEmployee.dari.value == "")
		{
			alert("Field : Dari tidak boleh kosong ...");
			document.FEmployee.dari.focus();
			return false;
		}

		if(document.FEmployee.sampai.value == "")
		{
			alert("Field : Sampai tidak boleh kosong ...");
			document.FEmployee.sampai.focus();
			return false;
		}

		if(document.FEmployee.no_ijazah.value == "")
		{
			alert("Field : No Ijazah tidak boleh kosong ...");
			document.FEmployee.no_ijazah.focus();
			return false;
		}

		if(document.FEmployee.tgl_ijazah.value == "")
		{
			alert("Field : Tanggal Ijazah tidak boleh kosong ...");
			document.FEmployee.tgl_ijazah.focus();
			return false;
		}

		if(document.FEmployee.ipk.value == "")
		{
			alert("Field : IPK tidak boleh kosong ...");
			document.FEmployee.ipk.focus();
			return false;
		}
*/
		document.FEmployee.submit();
		
	}
</script>
</head>
<form name="FEmployee" method="post" action="<?=$Faction?>">
<table width="100%">
 <tr>
  <td colspan="2">
	<table width="100%" style="border:none;">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>Data Pendidikan</b></td>
	</tr>
	<tr>
	 <tr>
	  <td>&nbsp;</td>
	 <td align="right" class="line_bottom">
	 <a href="../lib/detailemp.php?show=pribadi&amp;nik=<?=$nik?>">Data Pribadi</a> &raquo; 
	 <a href="../lib/detailemp.php?show=data_umum&amp;nik=<?=$nik?>">Data Umum</a> &raquo; 
	 <a href="../lib/detailemp.php?show=pendidikan&amp;nik=<?=$nik?>"><b>Pendidikan</b></a> &raquo; 
	 <a href="../lib/detailemp.php?show=kecakapan&amp;nik=<?=$nik?>">Kecakapan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=keluarga&amp;nik=<?=$nik?>">Keluarga</a> &raquo; 
	 <a href="../lib/detailemp.php?show=karir&amp;nik=<?=$nik?>">Pengalaman</a> &raquo; 
	 <a href="../lib/detailemp.php?show=organisasi&amp;nik=<?=$nik?>">Organisasi</a> 
	 </td>
	 </tr>
	</table>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
 <td>
 <table>
 <tr>
  <td width="150"><b>NIK</b></td>
  <td>: <input type="text" readonly="" maxlength="10" value="<?=$nik?>" value="<?=$row[NIK]?>" style="font-weight:bold;" class="text" name="nik" /> <span class="required">*</span></td>
 </tr>
  <tr>
  <td>Jenjang</td>
  <td>: 
  <select name="jenjang" id="JenjangPendidikan">
  <option value="">-Select-</option>
  <?php
  	$sP	= mssql_query("SELECT * FROM Jenjang ORDER BY ordernum",$conn);
	while($rP = mssql_fetch_array($sP)){
		if($rP[id]==$row[jenjang_id]) echo "<option value='$rP[id]' selected>$rP[nama]</option>";
		else echo "<option value='$rP[id]'>$rP[nama]</option>";
	}
  ?>
  </select>
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Fakultas</td>
  <td>: 
  <select name="fakultas" id="FakultasPendidikan">
  	<option value="">-Select-</option>
	  <?php
        $sP	= mssql_query("SELECT * FROM Fakultas where jenjang_id='$row[jenjang_id]' ORDER BY ordernum",$conn);
        while($rP = mssql_fetch_array($sP)){
            if($rP[id]==$row[fakultas_id]) echo "<option value='$rP[id]' selected>$rP[nama]</option>";
			else echo "<option value='$rP[id]'>$rP[nama]</option>";
        }
      ?>
  </select>
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Jurusan</td>
  <td>: 
  <select name="jurusan" id="JurusanPendidikan">
  <option value="">-Select-</option>
	  <?php
        $sP	= mssql_query("SELECT * FROM Jurusan where fakultas_id='$row[fakultas_id]' ORDER BY ordernum",$conn);
        while($rP = mssql_fetch_array($sP)){
            if($rP[id]==$row[jurusan_id]) echo "<option value='$rP[id]' selected>$rP[nama]</option>";
			else echo "<option value='$rP[id]'>$rP[nama]</option>";
        }
      ?>
  </select>
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Nama Kampus</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[NamaKampus]?>"  class="text" size="50" name="nama_kampus"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Tempat</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Tempat]?>"  class="text" size="50" name="tempat"/> <span class="required">*</span></td>
 <tr>
  <td>Sampai Kelas/Semester</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[SampaiKelas]?>" size="11"  class="text" name="sampai_kelas"/></td>
 <tr>
  <td>Dari</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tgl_dari]?>" size="11" class="text" name="dari"/><i> <a href="javascript:calB.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></i></td>
 </tr>
 <tr>
  <td>Sampai</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tgl_sampai]?>" size="11" class="text" name="sampai"/><i> <a href="javascript:calC.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></i></td>
 </tr>
  <td>No. Ijazah</td>
  <td>: <input type="text" maxlength="25" value="<?=$row[No_Ijasah]?>" class="text" name="no_ijazah"/></td>
 </tr>
 <tr>
  <td>Tanggal Ijazah</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tglijasah]?>" size="11"  class="text" name="tgl_ijazah"/> <a href="javascript:calA.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a>  </td>
 </tr>
 <tr>
  <td>IPK</td>
  <td>: <input type="text" maxlength="4" value="<?=$row[IPK]?>"  size="6" class="text" name="ipk"/></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td align="left"><br /><br />
  <input type="hidden" name="cat" value="pendidikan" />
  <input type="hidden" name="no" value="<?=$row[no]?>" />
  <input type="button" value="Batal" class="button" onclick="Javascript:history.back();"/><input type="button" value="<?=$Vbutton?>" class="button" onClick="Validate();" />
  <br /><br />  </td>
 </tr>
</table>
</form>
</td>
</tr>
<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>
<script type="text/javascript">

var f = document.forms[0];
MaskInput(f.tgl_ijazah,"99/99/9999");
MaskInput(f.dari,"99/99/9999");
MaskInput(f.sampai,"99/99/9999");
//MaskInput(f.ipk,"999");
//]]>
</script>
<script type="text/javascript">
// script untuk popup calendar
	var calA = new calendar1(document.forms['FEmployee'].elements['tgl_ijazah']);
	calA.year_scroll = true;
	calA.time_comp = false;	
	var calB = new calendar1(document.forms['FEmployee'].elements['dari']);
	calB.year_scroll = true;
	calB.time_comp = false;	
	var calC = new calendar1(document.forms['FEmployee'].elements['sampai']);
	calC.year_scroll = true;
	calC.time_comp = false;	

</script>

<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
